home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: Dec 3, 1996
- //
- // Description:
- // This script is a template script for option box dialogs.
- //
- // Input Arguments:
- // None.
- //
- // Return Vaalue:
- // None.
- //
-
- proc setOptionVars (int $forceFactorySettings)
- {
- if( $forceFactorySettings || !`optionVar -exists playblastUseStartEnd`) {
- optionVar -intValue playblastUseStartEnd 0;
- }
- if( $forceFactorySettings || !`optionVar -exists playblastStartTime`) {
- optionVar -floatValue playblastStartTime 1.0;
- }
- if( $forceFactorySettings || !`optionVar -exists playblastEndTime`) {
- optionVar -floatValue playblastEndTime 10.0;
- }
- if( $forceFactorySettings || !`optionVar -exists playblastViewerOn`) {
- optionVar -intValue playblastViewerOn 1;
- }
- if( $forceFactorySettings || !`optionVar -exists playblastOutputFormat`) {
- if(`about -linux`) {
- optionVar -stringValue playblastOutputFormat "iff";
- } else if (`about -mac`){
- optionVar -stringValue playblastOutputFormat "qt";
- } else {
- optionVar -stringValue playblastOutputFormat "sgi";
- }
- }
- if( $forceFactorySettings || !`optionVar -exists playblastCompression` ) {
- optionVar -stringValue playblastCompression "rle";
- }
- if( $forceFactorySettings || !`optionVar -exists playblastScale` ) {
- optionVar -floatValue
- playblastScale .5;
- }
- if( $forceFactorySettings || !`optionVar -exists playblastSaveToFile` ) {
- optionVar -intValue playblastSaveToFile 0;
- }
- if( $forceFactorySettings || !`optionVar -exists playblastFile` ) {
- string $filename = `file -q -sn`;
- if ($filename != "") {
-
- // extract the filename from the path
- //
- string $tokens[];
- tokenize($filename,"/",$tokens);
- $filename = $tokens[size($tokens)-1];
-
- // remove the extension from the filename
- //
- clear $tokens;
- tokenize($filename,".",$tokens);
- $filename = $tokens[0];
-
- } else {
- // no filename, use "playblast" as the default
- // playblast file name
- $filename = "playblast";
- }
- optionVar -stringValue playblastFile $filename;
- }
- if( $forceFactorySettings || !`optionVar -exists playblastShowOrnaments` ) {
- optionVar -intValue playblastShowOrnaments 1;
- }
- if( $forceFactorySettings || !`optionVar -exists playblastDisplaySizeSource` ) {
- optionVar -intValue playblastDisplaySizeSource 1;
- }
- if( $forceFactorySettings || !`optionVar -exists playblastWidth` ) {
- optionVar -intValue playblastWidth 256;
- }
- if( $forceFactorySettings || !`optionVar -exists playblastHeight` ) {
- optionVar -intValue playblastHeight 256;
- }
- if( $forceFactorySettings || !`optionVar -exists playblastClearCache` ) {
- optionVar -intValue playblastClearCache 1;
- }
- }
-
- global proc playblastSetup (string $parent, int $forceFactorySettings)
- {
- // Retrieve the option settings
- //
- setOptionVars( $forceFactorySettings );
- setParent $parent;
-
- // time range
- //
- int $useStartEnd = `optionVar -query playblastUseStartEnd`;
- radioButtonGrp -edit -select ($useStartEnd + 1) useStartEnd;
-
- float $startTime = `optionVar -query playblastStartTime`;
- floatFieldGrp -enable $useStartEnd -edit -value1 $startTime startTime;
-
- float $endTime = `optionVar -query playblastEndTime`;
- floatFieldGrp -enable $useStartEnd -edit -value1 $endTime endTime;
-
- // viewer
- //
- int $isViewer = `optionVar -query playblastViewerOn`;
- checkBoxGrp -edit -value1 $isViewer viewerOn;
-
- // Show ornaments
- //
- int $isShowOrnaments = `optionVar -query playblastShowOrnaments`;
- checkBoxGrp -edit -value1 $isShowOrnaments showOrnaments;
-
- // output format
- //
- string $format = `optionVar -query playblastOutputFormat`;
- if( $format == "iff") {
- radioButtonGrp -edit -select 2 format;
- } else {
- radioButtonGrp -edit -select 1 format;
- }
-
- if(`about -irix`) {
- // compression
- //
- string $compression = `optionVar -query playblastCompression`;
- if( $compression == "mvc1" ) {
- optionMenuGrp -edit -select 1 compression;
- }
- else if( $compression == "mvc2" ) {
- optionMenuGrp -edit -select 2 compression;
- }
- else if( $compression == "jpeg" ) {
- optionMenuGrp -edit -select 3 compression;
- }
- else if( $compression == "rle" ) {
- optionMenuGrp -edit -select 4 compression;
- }
- else if( $compression == "none" ) {
- optionMenuGrp -edit -select 5 compression;
- }
- else {
- optionMenuGrp -edit -select 1 compression;
- }
- optionMenuGrp -edit -enable ($format == "sgi") compression;
- }else if(`about -nt`) {
- button -edit -enable ($format == "sgi") compression;
- }else if(`about -linux`) {
- radioButtonGrp -edit -select 2 format;
- }else if (`about -mac`){
- button -edit -enable ($format == "qt") compression;
- }
-
-
- // scale
- //
- float $percent = `optionVar -query playblastScale`;
- floatSliderGrp -e -value $percent percent;
-
- // Display size
- //
- int $displayWidth = `optionVar -query playblastWidth`;
- int $displayHeight = `optionVar -query playblastHeight`;
- int $displaySource = `optionVar -query playblastDisplaySizeSource`;
- intFieldGrp -edit
- -value1 $displayWidth
- -value2 $displayHeight
- displaySizeField;
- optionMenuGrp -edit -select $displaySource displaySizeMenu;
- switch ($displaySource) {
- case 1:
- case 2:
- intFieldGrp -edit
- -enable false
- displaySizeField;
- break;
- case 3:
- intFieldGrp -edit
- -enable true
- displaySizeField;
- break;
- }
-
- // Save to file?
- //
- int $saveToFile = `optionVar -query playblastSaveToFile`;
- checkBoxGrp -e -value1 $saveToFile saveToFile;
- playblastSaveToFile( $saveToFile );
-
- // filename (note that optionVars should *not* be set
- // in this proc, setOptionVars() does that)
- //
- string $filename = `optionVar -query playblastFile`;
- textFieldGrp -e -fileName $filename movieFileName;
-
- // Clear Cache
- //
- int $isClearCache = `optionVar -query playblastClearCache`;
- checkBoxGrp -edit -value1 $isClearCache clearCache;
-
- }
-
- global proc playblastCallback( string $parent, int $doIt )
- //
- // Description:
- // Set the optionVar's from the control values, and then perform
- // the command
- //
- {
- setParent $parent;
-
- // Time Range.
- //
- int $useStartEnd = `radioButtonGrp -query -select useStartEnd`;
- optionVar -intValue playblastUseStartEnd ($useStartEnd - 1);
-
- float $startTime = `floatFieldGrp -query -value1 startTime`;
- optionVar -floatValue playblastStartTime $startTime;
-
- float $endTime = `floatFieldGrp -query -value1 endTime`;
- optionVar -floatValue playblastEndTime $endTime;
-
- // Viewer
- //
- int $isViewer = `checkBoxGrp -query -value1 viewerOn`;
- optionVar -intValue playblastViewerOn $isViewer;
-
- // Show ornaments
- //
- int $isShowOrnaments = `checkBoxGrp -query -value1 showOrnaments`;
- optionVar -intValue playblastShowOrnaments $isShowOrnaments;
-
- // Output format
- //
- int $selected = `radioButtonGrp -query -select format`;
- string $format;
-
- if( $selected == 2 )
- {
- $format = "iff";
- } else {
- if(`about -mac`){
- $format = "qt";
- }else{
- $format = "sgi";
- }
- }
- optionVar -stringValue playblastOutputFormat $format;
-
- // compression
- //
- string $compression;
- if(`about -irix`) {
- $selected = `optionMenuGrp -query -select compression`;
-
- if( $selected == 1 ) {
- $compression = "mvc1";
- } else if( $selected == 2 ) {
- $compression = "mvc2";
- } else if( $selected == 3 ) {
- $compression = "jpeg";
- } else if( $selected == 4 ) {
- $compression = "rle";
- } else {
- $compression = "none";
- }
- } else {
- $compression = "none";
- }
- optionVar -stringValue playblastCompression $compression;
-
- // scale
- //
- float $scale = `floatSliderGrp -q -value percent`;
- optionVar -floatValue playblastScale $scale;
-
- // Display size
- //
- int $displaySource = `optionMenuGrp -query -select displaySizeMenu`;
- optionVar -intValue playblastDisplaySizeSource $displaySource;
- if ($displaySource == 3) {
- int $displayWidth = `intFieldGrp -query -value1 displaySizeField`;
- int $displayHeight = `intFieldGrp -query -value2 displaySizeField`;
- optionVar -intValue playblastWidth $displayWidth;
- optionVar -intValue playblastHeight $displayHeight;
- }
-
- // Save to file
- //
- int $saveToFile = `checkBoxGrp -q -value1 saveToFile`;
- optionVar -intValue playblastSaveToFile $saveToFile;
-
- // filename
- //
- string $filename = `textFieldGrp -q -fileName movieFileName`;
- optionVar -stringValue playblastFile $filename;
-
- // Depends on where the callback comes from
- // From the Time Slider, $doIt is 2.
- //
- if( $doIt == 1 ) {
- performPlayblast 0;
- addToRecentCommandQueue "performPlayblast 0" "PlayBlast";
- } else if( $doIt == 2 ) {
- performPlayblast 3;
- addToRecentCommandQueue "performPlayblast 3" "PlayBlast";
- }
-
- // Clear cache
- //
- int $isClearCache = `checkBoxGrp -query -value1 clearCache`;
- optionVar -intValue playblastClearCache $isClearCache;
- }
-
- global proc int playblastUpdateMovieName( string $filename, string $fileType )
- {
- textFieldGrp -e -fileName $filename movieFileName;
- optionVar -stringValue playblastFile $filename;
- return 1;
- }
-
- global proc playblastMovieplayerFormat()
- {
- control -edit -enable true compression;
- textFieldGrp -e -l "Movie file" movieFileName;
- }
-
- global proc playblastQTFormat()
- {
- control -edit -enable true compression;
- textFieldGrp -e -l "Movie file" movieFileName;
- }
-
- global proc playblastFcheckFormat()
- {
- control -edit -enable false compression;
- textFieldGrp -e -l "Image file prefix" movieFileName;
- }
-
- global proc playblastSaveToFile( int $i )
- {
- if( $i ) {
- checkBoxGrp -e -value1 on saveToFile;
- textFieldGrp -e -enable true movieFileName;
- button -e -enable true browser;
- } else {
- checkBoxGrp -e -value1 on viewerOn;
- checkBoxGrp -e -value1 off saveToFile;
- textFieldGrp -e -enable false movieFileName;
- button -e -enable false browser;
- }
- }
-
- global proc playblastDisplaySizeMenuCB (string $tabLayout)
- {
- setParent $tabLayout;
-
- int $option = `optionMenuGrp -query -select displaySizeMenu`;
- switch ($option) {
- case 1: // From window
- case 2: // From render globals
- intFieldGrp -edit -enable false displaySizeField;
- break;
- case 3: // Custom
- intFieldGrp -edit -enable true displaySizeField;
- break;
- }
- }
-
- global proc playblastFileBrowser()
- {
- // only set the working directory if the
- // playblastFile optionVar is not an absolute
- // path
- //
- string $pathname;
- int $isAbsolute = false;
- if ( `optionVar -exists playblastFile` ) {
- string $filename = `optionVar -q playblastFile`;
- if ( $filename != "" &&
- (substring($filename,1,1) == "/"
- ||substring($filename,1,1) == "$") )
- {
- $isAbsolute = true;
- }
- }
-
- if ( !$isAbsolute ) {
-
- // get the workspace
- //
- string $workspace = `workspace -q -fn`;
-
- // get the project's image directory
- //
- string $fileRules[] = `workspace -q -fr`;
- int $i;
- string $imageDir = ""; // default is current dir
- for ( $i = 0; $i < size($fileRules); $i += 2 ) {
- if ( $fileRules[$i] == "image" ) {
- $imageDir = $fileRules[$i+1];
- break;
- }
- }
-
- if ( $imageDir != "" ) {
- // set the current working directory
- //
- setWorkingDirectory $workspace "image" $imageDir;
- }
- }
-
- // win32 should be "save to" since "open" requires an existing file
- fileBrowser("playblastUpdateMovieName","Accept","",1);
- }
-
-
- proc string playblastBasic( string $tabLayout, int $hideTimeRange )
- {
- setParent $tabLayout;
-
- string $tabForm = `columnLayout -adjustableColumn true`;
-
- // Time Range
- //
- frameLayout -bv no -lv no -collapsable yes -collapse $hideTimeRange
- startEndFrame;
- columnLayout -adjustableColumn true;
- radioButtonGrp -l "Time Range" -nrb 2
- -changeCommand ( "floatFieldGrp -e -enable (`radioButtonGrp -q -sl useStartEnd` == 2) startTime; floatFieldGrp -e -enable (`radioButtonGrp -q -sl useStartEnd` == 2) endTime; ")
- -select 1
- -label1 "Time Slider"
- -l2 "Start/End"
- useStartEnd;
-
- floatFieldGrp -enable 0 -label "Start Time" -value1 0.0 startTime;
- floatFieldGrp -enable 0 -label "End Time" -value1 10.0 endTime;
-
- separator -style "in" -w 1000;
-
- setParent ..;
- setParent ..;
-
- // Make viewer on/off button.
- //
- checkBoxGrp -l "View" -ncb 1 -value1 on -l1 ""
- -offCommand "playblastSaveToFile true" viewerOn;
-
- // Show ornaments
- //
- int $isShowOrnaments = `optionVar -query playblastShowOrnaments`;
- checkBoxGrp -label "Show Ornaments"
- -numberOfCheckBoxes 1
- -label1 ""
- showOrnaments;
-
- separator -style "in" -w 1000;
-
- // Output format
- //
- if(`about -linux`) {
- radioButtonGrp -l "Viewer"
- -nrb 2
- -label1 "xanim "
- -cc1 "playblastMovieplayerFormat"
- -en1 false
- -label2 "fcheck"
- -cc2 "playblastFcheckFormat"
- -select 2
- format;
- }else if(`about -mac`) {
- radioButtonGrp -l "Viewer"
- -nrb 2
- -label1 "QuickTime "
- -cc1 "playblastQTFormat"
- -label2 "fcheck"
- -cc2 "playblastFcheckFormat"
- -select 2
- format;
- }else{
- radioButtonGrp -l "Viewer"
- -nrb 2
- -label1 "Movieplayer "
- -cc1 "playblastMovieplayerFormat"
- -label2 "fcheck"
- -cc2 "playblastFcheckFormat"
- -select 1
- format;
- }
-
- // Compression
- //
- if (`about -nt`) {
- rowLayout -nc 2 -cw 1 170 -cw 2 240 -cal 2 "center";
- text -l "";
- button -l "Compression..." -enable true -c "playblast -options" compression;
- setParent ..;
- }else if (`about -linux`) {
- optionMenuGrp -l "Compression" -enable false compression;
- setParent -m ..;
- }else if(`about -irix`) {
- optionMenuGrp -l "Compression" -enable true compression;
- menuItem -l "MVC1";
- menuItem -l "MVC2";
- menuItem -l "JPEG";
- menuItem -l "RLE";
- menuItem -l "None";
- setParent -m ..;
- }else if (`about -mac`) {
- rowLayout -nc 2 -cw 1 170 -cw 2 240 -cal 2 "center";
- text -l "";
- button -l "Compression..." -enable true -c "playblast -options" compression;
- setParent ..;
- }else{
- optionMenuGrp -l "Compression" -enable true compression;
- setParent -m ..;
- }
-
- separator -style "in" -w 1000;
-
- // Display size
- //
- optionMenuGrp -label "Display Size"
- -changeCommand ("playblastDisplaySizeMenuCB " + $tabLayout)
- displaySizeMenu;
- menuItem -label "From Window";
- menuItem -label "From Render Globals";
- menuItem -label "Custom";
- setParent -menu ..;
- intFieldGrp -label ""
- -numberOfFields 2
- displaySizeField;
-
- // Scale
- //
- floatSliderGrp -field yes -min .1 -max 1.0 -pre 2 -label "Scale" percent;
-
- separator -style "in" -w 1000;
-
- // Clear cache
- //
- int $isClearCache = `optionVar -query playblastClearCache`;
- checkBoxGrp -label "Remove Temporary Files"
- -numberOfCheckBoxes 1
- -label1 ""
- clearCache;
-
- // Save to file
- //
- checkBoxGrp -l "Save to File" -ncb 1 -value1 off -l1 "" -cc1 "playblastSaveToFile #1"
- saveToFile;
-
- // Filename
- //
- if(`about -linux`){
- textFieldGrp -l "Image file prefix" -enable false movieFileName;
- }else{
- textFieldGrp -l "Movie file" -enable false movieFileName;
- }
-
- // Browser
- //
- rowLayout -nc 2 -cw 1 170 -cw 2 240 -cal 2 "center";
- text -l "";
- button -l "Browse..." -align "center" -enable false -c
- "playblastFileBrowser" browser;
- setParent ..;
-
- return $tabForm;
- }
-
- global proc playblastOptions( int $hideTimeRange )
- {
- // Name of the command for this option box
- //
- string $commandName = "playblast";
-
- // Title for the option box window
- //
- string $optionBoxTitle = "Playblast Options";
-
- // Title for the apply button
- //
- string $applyTitle = "Playblast";
-
- // Build the option box "methods"
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- // Build the window, with a tab layout
- //
- string $widgetList[] = `getStandardWindow $optionBoxTitle 0 "noOptions"`;
- setUITemplate -pushTemplate DefaultTemplate;
-
- // Make the form invisible while we create the widgets in the window
- //
- formLayout -e -vis false $widgetList[1];
-
- // Put the widgets in the layout
- //
- playblastBasic $widgetList[2] $hideTimeRange;
-
- // Attach the standard buttons
- //
- string $buttonList[] = `addStandardButtons $commandName $applyTitle $widgetList[1] $widgetList[2] "noOptions"`;
-
- // attach commands to the standard buttons
- //
- // Save
- //
- button -e -c ($callback + " " + $widgetList[0] + " false" +
- "; hideOptionBox()") $buttonList[3];
-
- // Close
- //
- button -edit -command hideOptionBox $buttonList[2];
-
- // Reset
- //
- button -edit -command ($setup + " " + $widgetList[0] + " true")
- $buttonList[1];
-
- // Do It
- // Note: JUST for the Playblast option box, when you do the Playblast,
- // it will delete the option box window. This is because the Playblast
- // operation pushes the Maya window to the front to do the screen grabs,
- // and the option box would remain open but unseen by the user.
- //
- button -edit -command ("window -edit -i true " + $widgetList[0] + "; " +
- $callback + " " + $widgetList[0] + " " +
- ( 1 + $hideTimeRange ) + " " +
- "; hideOptionBox()")
- $buttonList[0];
-
- // Make the form layout visible so we can see what we built, and
- // reset the template
- //
- formLayout -e -vis true $widgetList[1];
- setUITemplate -popTemplate;
-
- // Customize the 'Help' menu item text.
- //
- setOptionBoxHelpTag( "Playblast" );
-
- // Call the setup "method" to fill in the current settings
- //
- eval (($setup + " " + $widgetList[0] + " false"));
- showOptionBox();
- showWindow $widgetList[0];
- }
-
- proc string assembleCmd( int $useTimeSliderHighlight )
- //
- // Description:
- //
- //
- {
- int $useStartEnd;
-
- // This makes sure that when we're called from the time slider, we
- // _never_ look at the start/end values in the option box, since they're
- // not displayed in that version of the option box anyway.
- //
- if( $useTimeSliderHighlight ) {
- $useStartEnd = 0;
- } else {
- $useStartEnd = `optionVar -query playblastUseStartEnd`;
- }
-
- string $cmd = "doPlayblastArgList 3 { " +
- "\"" + `optionVar -query playblastSaveToFile` + " \"" +
- ",\"" + `optionVar -query playblastFile` + "\"" +
- ",\"" + `optionVar -query playblastViewerOn` + "\"" +
- ",\"" + `optionVar -query playblastOutputFormat` + "\"" +
- ",\"" + `optionVar -query playblastShowOrnaments` + "\"" +
- ",\"" + `optionVar -query playblastScale` + "\"" +
- ",\"" + `optionVar -query playblastCompression` + "\"" +
- ",\"" + `optionVar -query playblastDisplaySizeSource` + "\"" +
- ",\"" + `optionVar -query playblastWidth` + "\"" +
- ",\"" + `optionVar -query playblastHeight` + "\"" +
- ",\"" + $useStartEnd + "\"" +
- ",\"" + `optionVar -query playblastStartTime` + "\"" +
- ",\"" + `optionVar -query playblastEndTime` + "\"" +
- ",\"" + `optionVar -query playblastClearCache` + "\"" +
- "};";
-
- return $cmd;
- }
-
-
- global proc string performPlayblast( int $action )
- {
- string $cmd = "";
-
- switch( $action ) {
- case 0:
- setOptionVars( false );
- $cmd = `assembleCmd 0`;
- eval( $cmd );
- break;
- case 1:
- playblastOptions 0;
- break;
- case 2:
- setOptionVars( false );
- $cmd = `assembleCmd 0`;
- break;
- case 3:
- setOptionVars( false );
- $cmd = `assembleCmd 1`;
- eval( $cmd );
- break;
- case 4:
- playblastOptions 1;
- break;
- }
-
- return $cmd;
- }
-